/*
@param {*} success 数据库成功回调
@param {*}  error  数据库失败回调
*/
module.exports=function(success,error){
const mongoose=require('mongoose');
mongoose.set('strictQuery',true);

const{DBHOST,DBPORT,DBNAME}=require('./host');

mongoose.connect(`mongodb://${DBHOST}:${DBPORT}/${DBNAME}`);
//4.设置成功回调 once一次 只执行一次
mongoose.connection.once('open',()=>{
success();
});
mongoose.connection.on('close',()=>{
    console.log('连接关闭');
});
mongoose.connection.on('err',()=>{
   error();
});
}